<?php
namespace app\index\controller;

use think\facade\View;
use think\facade\Db;
use think\facade\Request;
use think\facade\Session;

/**
 * 通过生成资源链接
 * 发给客户,客户打开页面点击下载,然后资源失效
 * 资源链接参数加密
 * 下载地址参数加密
 */
class Down extends Front
{
    public function index()
    {
        return View::fetch('index');
    }
    public function download()
    {
        return download('images/20200417130819785.jpg','a1.jpg');
    }
    public function downpage()
    {
        $id = 2;
        $data = \app\index\model\Resource::find($id);

        die;
    }
    public function createResource()
    {
        $data = [
            'resource_type'=>'file',
            'resource_name'=>'设计图',
            'resource_token'=>'1221',
            'resource_link'=>'',
            'create_time'=>time(),
            'resource_expire'=>time()+30
        ];
        $data = \app\index\model\Resource::create($data);
        $data->resource_link = '/down/downpage?id='.$data->id;
        $data->save();
        die('处理完成');
    }
}
